Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ssr): update wire adapter validation @ W-17274788 #4910

Merged
merged 13 commits into from
Nov 21, 2024
Merged

Conversation

wjhsf
Copy link
Contributor

@wjhsf wjhsf commented Nov 21, 2024

Details

The original wire adapter implementation made some incorrect assumptions (e.g. all values look like "$string"); this PR updates the logic to better match engine-server.

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.
  • 💔 Yes, it does introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.
  • 🔬 Yes, it does include an observable change.

GUS work item

@wjhsf wjhsf requested a review from a team as a code owner November 21, 2024 17:38
const { decorators } = node;

if (decorators.length > 1) {
throw new Error('todo - multiple decorators at once');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Fix these error messages.

path: NodePath<PropertyDefinition | MethodDefinition>
): asserts config is NoSpreadObjectExpression {
if (!is.objectExpression(config)) {
throw new Error('todo - CONFIG_OBJECT_SHOULD_BE_SECOND_PARAMETER');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: add fixtures validating all the error messages

throw new Error('Invalid config provided to @wire decorator; expected an object literal.');
for (const property of config.properties) {
// Only validate computed object properties because static props are all valid
// and we ignore {...spreads} and {methods(){}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: add a test for spreads.

__connectContext(${/*wire adapter constructor*/ 0}, instance, (newContextValue) => {
const wireConfigObj = ${/*mapping from lwc fields to wire config keys*/ 2};
wireInstance.update(wireConfigObj, newContextValue);
wireInstance.update(getLiveConfig(), newContextValue);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: add a test for this being two different live values across two updates, to ensure in the future we don't mistakenly just set the variable once.

@wjhsf wjhsf enabled auto-merge (squash) November 21, 2024 19:28
@wjhsf wjhsf merged commit e60891b into master Nov 21, 2024
11 checks passed
@wjhsf wjhsf deleted the mob/yaaaay branch November 21, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants